package KnightsTour.GUI;

import KnightsTour.Controller.Controller;
import KnightsTour.ChessBoard;
import java.awt.BorderLayout;
import java.awt.Toolkit;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.*;
import javax.swing.event.MouseInputListener;

/**
 *
 * @author Scott Robinson
 */
public class Frame extends JFrame{

    private ChessboardPanel cbp;
    private final int HEIGHT = 700;
    private final int WIDTH = 600;
    private final Controller controller;
    private ChessBoard cb;
    private final String INSTRUCTIONS =
            "You may only access each square once and only once and you will move exactly\n" +
            "as a knight would move on a chessboard.  Just click (or double click as sometimes it sticks)\n" +
            "the square you want to move to and you will see the counter marking the squares\n" +
            "you have already visited.  If you access all 64 squares, you win!  Good luck!";


    public Frame (String title) {
        super (title);
        cb = new ChessBoard();
        cbp = new ChessboardPanel(cb);
        controller = new Controller (cbp, cb, this);

        setLayout(new BorderLayout());
        add(cbp, BorderLayout.CENTER);
        //setSize(cbp.getPreferredSize());
        setSize(WIDTH, HEIGHT);

        setLocation(Toolkit.getDefaultToolkit ().getScreenSize().width / 2 - WIDTH / 2,
                Toolkit.getDefaultToolkit ().getScreenSize().height / 2 - HEIGHT / 2);

    }

    public ChessboardPanel resetBoard() {
        remove (cbp);
        cb = new ChessBoard();
        cbp = new ChessboardPanel(cb);
        add(cbp, BorderLayout.CENTER);
        return cbp;
    }

    public void displayInstructions() {
        JOptionPane.showMessageDialog(this, INSTRUCTIONS);
    }
}
